package file;

import java.io.File;
import java.io.FileFilter;

public class ListFilesDemo2 {
    public static void main(String[] args) {
        File file = new File("./a");
//        FileFilter filter = new FileFilter() {
//
//            @Override
//            public boolean accept(File pathname) {
//                String name = pathname.getName();
//                return name.endsWith(".txt");
//            }
//        };

        if(file.isDirectory()) {
            File[] subs = file.listFiles(sub -> sub.getName().endsWith(".txt"));
            for(File sub : subs) {
                System.out.println(sub.getName());
            }
        }
    }
}
